[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
clearerr() Clear Error Indicator for a Stream
#include <stdio.h>
void clearerr(stream);
FILE *stream; Pointer to file structure
clearerr() sets the error and end-of-file indicators of the 'stream'
to 0.
Returns: Nothing
Notes: Once set, a stream's indicators are not automatically
cleared by subsequent operations; operations to the
stream will continue to return an error either until
clearerr() or rewind() is called, or the stream is
closed.
-------------------------------- Example ---------------------------------
The following statements open a file, get characters from the file,
report an error, then clear the indicators (if necessary) and close
the file.
#include <stdio.h>
FILE *stream;
int c;
main()
{
if ((stream = fopen("new.txt","r+"))!= NULL) {
while (!feof(stream)){
c = getc(stream);
if (ferror(stream)) {
printf("write error\n");
clearerr(stream);
}
}
fclose(stream);
}
}
See Also:
eof()
feof()
ferror()
perror()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson